package com.canaan.business.service.storehouse.impl;

import com.canaan.business.common.enums.storehouse.StoreHouseTypeEnum;
import com.canaan.business.domain.basic.WmsStorehouse;
import com.canaan.business.domain.vo.WmsStorehouseStockVo;
import com.canaan.business.mapper.basic.WmsStorehouseMapper;
import com.canaan.business.mapper.storehouse.WmsStorehouseStockMapper;
import com.canaan.business.service.storehouse.IWmsStockInStockStrategyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class WmsStockInStockByMinRowMinColumnServiceImpl implements IWmsStockInStockStrategyService {
    @Resource
    WmsStorehouseStockMapper storehouseStockMapper;
    @Resource
    WmsStorehouseMapper storehouseMapper;
    @Override
    public WmsStorehouseStockVo getEmptyStock() {
        WmsStorehouse query=new WmsStorehouse();
        query.setTypeNo(StoreHouseTypeEnum.PRODUCT.getCode());
        query.setDelFlag("0");
        List<WmsStorehouse> wmsStorehouses=storehouseMapper.selectWmsStorehouseList(query);
        if(wmsStorehouses==null||wmsStorehouses.size()==0){
            throw new RuntimeException("成品仓不存在");
        }
        List<WmsStorehouseStockVo> storehouseStocks=storehouseStockMapper.selectEmpWmsStorehouseStockListMinRowMinColumn();
        if(storehouseStocks==null||storehouseStocks.size()==0){
            throw new RuntimeException("成品仓不存在空库位");
        }

        return storehouseStocks.get(0);
    }
    @Override
    public List<WmsStorehouseStockVo> getEmptyStocks() {
        WmsStorehouse query=new WmsStorehouse();
        query.setTypeNo(StoreHouseTypeEnum.PRODUCT.getCode());
        query.setDelFlag("0");
        List<WmsStorehouse> wmsStorehouses=storehouseMapper.selectWmsStorehouseList(query);
        if(wmsStorehouses==null||wmsStorehouses.size()==0){
            throw new RuntimeException("成品仓不存在");
        }
        List<WmsStorehouseStockVo> storehouseStocks=storehouseStockMapper.selectEmpWmsStorehouseStockListMinRowMinColumn();
        if(storehouseStocks==null||storehouseStocks.size()==0){
            throw new RuntimeException("成品仓不存在空库位");
        }

        return storehouseStocks;
    }
}
